from huobi.HuobiServices import *
#myjson = json.loads('{"btc":0,"ltc":0,"eth":0}')
#myjson['btb'] = 1123
#mykey = myjson.keys()
#print('btb' in myjson.keys())
#hb = btcserver.huobi.HuobiServices
#hh = get_accounts()
#hh = get_balance("485514")
#print(hh)
#id = hh['data'][0]['id']
#print(id)
#dd = get_balance(id)
#s = json.loads(hh)
#print(dd)
#ff = dd['data']['list']
#for i in ff:
#    print(i['currency'])

def GetCoinNum(coinjson, ak, sk):
    myapi = get_accounts(ak, sk)
    id = myapi['data'][0]['id']
    coins = get_balance(ak, sk, id)
    #print(coins)
    myCoins = coins['data']['list']
    for i in myCoins:
        num = (float)(i['balance'])
        if num > 0:
            if (i['currency'] in coinjson.keys()):
                coinjson[i['currency']] = coinjson[i['currency']] + num
            else:
                coinjson[i['currency']] = num

